/*
 * @Author: biankai
 * @Date: 2021-11-04 14:27:50
 * @LastEditTime: 2021-11-10 14:27:53
 * @LastEditors: biankai
 * @FilePath: /gitee/devops_service/src/services/jenkins/build.service.ts
 */
import {
    Injectable,
    Inject,
    HttpService,
    BadRequestException,
} from '@nestjs/common';
import { BaseService } from './base.service';
@Injectable()
export class BuildService extends BaseService {

    constructor(@Inject(HttpService) private readonly httpService: HttpService) {
        super()
    }

    async buildGet(buildName, buildNum) {
        const resBody = await this.jenkinsObj.build.get(buildName, buildNum,)
        return await resBody;
    }

    async buildLog(buildName, buildNum) {
        const resBody = await this.jenkinsObj.build.log(buildName, buildNum,)
        return await resBody;
    }
    async buildLogStream(buildName, buildNum) {
        const resBody = await this.jenkinsObj.build.logStream(buildName, buildNum)
        return await resBody;
    }
    async buildStop(buildName, buildNum) {
        const resBody = await this.jenkinsObj.build.stop(buildName, buildNum,)
        return await resBody;
    }
    async buildTerm(buildName, buildNum) {
        const resBody = await this.jenkinsObj.build.term(buildName, buildNum,)
        return await resBody;
    }

    // async queueList() {
    //     const resBody = await this.jenkinsObj.queue.list()
    //     return await resBody;
    // }

    // async queueItem(num) {
    //     const resBody = await this.jenkinsObj.queue.item(num)
    //     return await resBody;
    // }

    // async queueCancel(num) {
    //     const resBody = await this.jenkinsObj.queue.cancel(num)
    //     return await resBody;
    // }
}
